home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’96 / Talking Telnet / source / Speech / DoSpeechError.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-22  |  1.6 KB  |  54 lines  |  [TEXT/CWIE]

  1. #include    "speech.proto.h"
  2. #include    "errors.proto.h"
  3. #include    "telneterrors.h"
  4. #include    <Errors.h>
  5. #include    <TextUtils.h>
  6.  
  7.  
  8. OSErr gSpeechErrors[] = {
  9.     noErr,                /* No error */
  10.     paramErr,            /* Parameter error */
  11.     memFullErr,            /* Not enough memory to speak */
  12.     nilHandleErr,        /* Handle argument is NIL */
  13.     siUnknownInfoType,    /* Feature not implemented on synthesizer */
  14.     noSynthFound,        /* Could not find the specified speech synthesizer */
  15.     synthOpenFailed,    /* Could not open another speech synthesizer channel */
  16.     synthNotReady,        /* Speech synthesizer is still busy speaking */
  17.     bufTooSmall,        /* Output buffer is too small to hold result */
  18.     voiceNotFound,        /* Voice resource not found */
  19.     incompatibleVoice,    /* Specified voice cannot be used with synthesizer */
  20.     badDictFormat,        /* Pronunciation dictionary format error */
  21.     badInputText,        /* Raw phoneme text contains invalid characters */
  22.     -248,                /* Unimplemented message */
  23.     -250,                /* Specified voice has not been preloaded */
  24.     -252,                /* Incorrect number of embedded command arguments */
  25.     invalidComponentID,    /* Speech channel is uninitialized or bad */
  26.     0,                    /* other error */
  27. };
  28.  
  29.  
  30. void DoSpeechError(OSErr err)
  31. {
  32.     short    e;
  33.     Str255    errorMessage;
  34.     
  35.     /* use the last error as a sentinel, so the loop is guaranteed to terminate */
  36.     
  37.     gSpeechErrors[sizeof(gSpeechErrors)/sizeof(*gSpeechErrors)] = err;
  38.  
  39.     /* Find the correct index, which is 1 + array index */
  40.     
  41.     e = 0;
  42.     while (err != gSpeechErrors[e++]) {
  43.     }
  44.     
  45.     /* Get the string */
  46.     
  47.     GetIndString(errorMessage, kSpeechIndStringId, e);
  48.     
  49.     /* And do the error */
  50.     
  51.     p2cstr(errorMessage);
  52.     DoError(NOCODE, LEVEL2, (char *)errorMessage);
  53. }
  54.